package com.neuedu.nevserver.controller;

import com.neuedu.nevserver.pojo.SlauBatch;
import com.neuedu.nevserver.service.SlauBatchService;
import com.neuedu.nevserver.vo.NodeSlauBatchProdcutTypeVO;
import com.neuedu.nevserver.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sjy
 * @since 2025-03-18
 */
@RestController
@RequestMapping("/slau-batch")
@Api(tags="屠宰企业批号管理",description = "提供屠宰企业批号管理API接口")
public class SlauBatchController {
    @Autowired
    private SlauBatchService slauBatchService;

    @PostMapping("/addSlauBatch")
    @ApiOperation("新增屠宰企业批号")
    public ResultVO addSlauBatch(SlauBatch slauBatch) throws Exception{
        slauBatch.setBatchDate(new Date());
        slauBatchService.save(slauBatch);
        return ResultVO.success("新增成功");
    }

    @GetMapping("/listSlauBatch")
    @ApiOperation("查询屠宰企业产品批号列表")
    public ResultVO<List<SlauBatch>> listSlauBatch(SlauBatch slauBatch) throws Exception{
        return slauBatchService.listSlauBatch(slauBatch);
    }

    @PostMapping("/queryNodeSlauBatchProdcutTypeVO")
    @ApiOperation("根据养殖企业产品批号查询屠宰产品批号列表")
    public ResultVO<List<NodeSlauBatchProdcutTypeVO>> queryNodeSlauBatchProdcutTypeVO(Integer fbId) throws Exception {
        return slauBatchService.selectNodeSlauBatchProdcutTypeVO(fbId);
    }
}
